package com.huanuo.internetofthings.controller.jasperStatus;

import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMethod;
import org.unicorn.framework.core.ResponseDto;
import org.unicorn.framework.core.exception.PendingException;
import com.huanuo.internetofthings.service.jasperStatus.JasperStatusService;
import com.huanuo.internetofthings.dto.jasperStatus.JasperStatusPageRequestDto;
import com.huanuo.internetofthings.bo.jasperStatus.JasperStatus;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * <p>
 * 控制器
 * </p>
 *
 * @author xiebin
 * @since 2018-08-16
 */
@RestController
@RequestMapping("/jasperStatus")
public class JasperStatusController {
	@Autowired
    private JasperStatusService jasperStatusService;
    
    /**
	 * 新增记录
	 * @param jasperStatus
	 * @return
	 * @throws PendingException
	 */
	@RequestMapping(value = { "/save" }, method = { RequestMethod.POST })
	public ResponseDto<?> save(@RequestBody JasperStatus  jasperStatus) throws PendingException {
		return new ResponseDto<>(jasperStatusService.save(jasperStatus));
	}
	
	 /**
	 * 根据主键删除
	 * @param jasperStatus
	 * @return
	 * @throws PendingException
	 */
	@RequestMapping(value = { "/delete/{id}" }, method = { RequestMethod.GET })
	public ResponseDto<?> delete(@PathVariable("id") Integer  id) throws PendingException {
		jasperStatusService.deleteByPrimaryKey(id);
		 return new ResponseDto<>();
	}
	
	 /**
	 * 根据主键编辑
	 * @param jasperStatus
	 * @return
	 * @throws PendingException
	 */
	@RequestMapping(value = { "/edit" }, method = { RequestMethod.POST })
	public ResponseDto<?> edit(@RequestBody JasperStatus  jasperStatus) throws PendingException {
		return new ResponseDto<>(jasperStatusService.updateByPrimaryKey(jasperStatus));
	}
	
	/**
	 * 根据主键查询
	 * @param jasperStatus
	 * @return
	 * @throws PendingException
	 */
	@RequestMapping(value = { "/{id}" }, method = { RequestMethod.GET })
	public ResponseDto<?> queryByPrimaryKey(@PathVariable("id") Integer  id) throws PendingException {
		return new ResponseDto<>(jasperStatusService.selectByPrimaryKey( id));
	}
	
	/**
	 * 根据条件查询单条信息
	 * @param jasperStatus
	 * @return
	 * @throws PendingException
	 */
	@RequestMapping(value = { "/query" }, method = { RequestMethod.POST })
	public ResponseDto<?> query(@RequestBody JasperStatus  jasperStatus) throws PendingException {
		return new ResponseDto<>(jasperStatusService.selectOne( jasperStatus));
	}
	
	/**
	 * 根据条件查询-分页
	 * @param jasperStatus
	 * @return
	 * @throws PendingException
	 */
	@RequestMapping(value = { "/query/page" }, method = { RequestMethod.POST })
	public ResponseDto<?> query(@RequestBody JasperStatusPageRequestDto jasperStatusPageRequestDto) throws PendingException {
		return new ResponseDto<>(jasperStatusService.getJasperStatusByPage( jasperStatusPageRequestDto));
	}
}
